﻿using System;

namespace VitCode.ObjectResolutionHelper
{
    /// <summary>
    /// 应该于类名称或属性名称的自定义描述
    /// </summary>
    [AttributeUsage(AttributeTargets.All)]
    public class OrMemoAttribute : Attribute
    {
        // 摘要:
        //     Specifies the default value for the System.ComponentModel.DescriptionAttribute,
        //     which is an empty string (""). This static field is read-only.
        public static readonly OrMemoAttribute Default = new OrMemoAttribute("");

        // 摘要:
        //     Initializes a new instance of the System.ComponentModel.DescriptionAttribute
        //     class with no parameters.
        public OrMemoAttribute()
        {
        }

        //
        // 摘要:
        //     Initializes a new instance of the System.ComponentModel.DescriptionAttribute
        //     class with a description.
        //
        // 参数:
        //   description:
        //     The description text.
        public OrMemoAttribute(string description)
        {
            DescriptionValue = description;
        }

        // 摘要:
        //     Gets the description stored in this attribute.
        //
        // 返回结果:
        //     The description stored in this attribute.
        public virtual string Description
        {
            get { return DescriptionValue; }
        }

        //
        // 摘要:
        //     Gets or sets the string stored as the description.
        //
        // 返回结果:
        //     The string stored as the description. The default value is an empty string
        //     ("").
        protected string DescriptionValue { get; set; }

        //
        // 摘要:
        //     Returns a value indicating whether this is the default System.ComponentModel.DescriptionAttribute
        //     instance.
        //
        // 返回结果:
        //     true, if this is the default System.ComponentModel.DescriptionAttribute instance;
        //     otherwise, false.
        public override bool IsDefaultAttribute()
        {
            return Default.Equals(this);
        }
    }
}